home *** CD-ROM | disk | FTP | other *** search
- { strdemo2.pas -- Dynamic importing demonstration }
-
- program StrDemo2;
-
- uses WinTypes, WinProcs, WinCrt, Strings;
-
- type
-
- TStrNCopy = function(Source: String; var P: PChar): PChar;
- TStrTok = function(var Next: PChar; P: PChar; C: Char): PChar;
- TStrFill = procedure(P: PChar; C: Char; Size: Word);
-
- var
-
- HStr: THandle;
- StrNCopy: TStrNCopy;
- StrTok: TStrTok;
- StrFill: TStrFill;
- Next: PChar;
-
- {- Variables from StrDemo1 (plus P) }
-
- Buffer: array[0 .. 80] of Char;
- P, DeviceName, DriverName, OutputName: PChar;
- A: array[0 .. 40] of Char;
-
- begin
- HStr := LoadLibrary('STRDLL.DLL');
- if HStr < 32 then
- Writeln('*** Error loading STRDLL.DLL library file ***')
- else begin
- @StrNCopy := GetProcAddress(HStr, 'STRNCOPY');
- @StrTok := GetProcAddress(HStr, 'STRTOK');
- @StrFill := GetProcAddress(HStr, 'STRFILL');
- GetProfileString('windows', 'device', ',,', Buffer, Sizeof(Buffer));
- Writeln('Original string = ', Buffer);
- StrNCopy(Buffer, P);
- if P <> nil then
- begin
- Writeln('Copy of original = ', P);
- StrDispose(P)
- end;
- Next := nil;
- DeviceName := StrTok(Next, Buffer, ',');
- DriverName := StrTok(Next, nil, ',');
- OutputName := StrTok(Next, nil, ',');
- Writeln('Device name = ', DeviceName);
- Writeln('Driver name = ', DriverName);
- Writeln('Output name = ', OutputName);
- Writeln;
- StrFill(A, '-', SizeOf(A));
- Writeln('Filled A = ', A);
- Writeln;
- Writeln('Press Alt+F4 to close window');
- FreeLibrary(HStr)
- end
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 5/25/1991
- ---------------------------------------------------------------}
-